package www.wen.com.common.lib.helper.loading

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.dylanc.loadinghelper.LoadingHelper
import www.wen.com.common.R


/**
 * @author WEN
 * @Description: 空数据占位
 * @date 2020/12/8 14:52
 */
class EmptyAdapter : LoadingHelper.Adapter<EmptyAdapter.ViewHolder>() {

    override fun onBindViewHolder(holder: ViewHolder) {
        holder.emptyView.setOnClickListener {
            if (holder.onReloadListener != null) {
                holder.onReloadListener!!.onReload()
            }
        }
    }

    override fun onCreateViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup
    ): ViewHolder {
        return ViewHolder(inflater.inflate(R.layout.layout_empty, parent, false))
    }

    class ViewHolder internal constructor(rootView: View) : LoadingHelper.ViewHolder(rootView) {

        val emptyView: View = rootView.findViewById(R.id.EmptyView)

    }

}